﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GenericStudy
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                var type = typeof(Dictionary<,>);
                PrintType(type);
            }

            Console.WriteLine();

            {
                var type = typeof(Dictionary<string, int>);
                PrintType(type);
            }

            Console.WriteLine();

            {
                var type = typeof(Test<>).BaseType;
                PrintType(type);
            }
        }

        private static void PrintType(Type type)
        {
            Console.WriteLine(type);
            Console.WriteLine("IsGenericType:" + type.IsGenericType);
            Console.WriteLine("IsGenericTypeDefinition:" + type.IsGenericTypeDefinition);
            Console.WriteLine("IsGenericParameter:" + type.IsGenericParameter);

            if (type.IsGenericType)
            {
                Console.WriteLine(type.GetGenericTypeDefinition() == type);

                foreach (var item in type.GetGenericArguments())
                {
                    PrintType(item);
                }
            }
        }
    }

    internal class Test<TValue> : Dictionary<string, TValue>
    {
    }
}
